import Book.BookList;
import user.AdminUser;
import user.NomalUser;
import user.User;

import java.util.Scanner;

public class Main {

    public static User login(){
        Scanner scanner=new Scanner(System.in);
        System.out.println("请输入你的姓名：");
        String name=scanner.nextLine();
        System.out.println("请输入你的身份：1-》管理员  0-》普通用户");
        while (true){
            int choice=scanner.nextInt();
            if (choice==1){
                System.out.println("*************************");
                return new AdminUser(name);
            } else if (choice==0) {
                System.out.println("*************************");
                return new NomalUser(name);
            }else {
                System.out.println("输入错误，请重新输入！");
            }
        }

    }


    public static void main(String[] args) {
        BookList bookList=new BookList();

        User user=login();

        System.out.println("hello "+user.name+" 欢迎来到图书管理系统！");


        while (true){
            int ret=user.menu();
            if (ret> user.choicenum||ret<0){
                System.out.println("操作错误！");
                System.out.println("*************************");
                continue;
            }

            user.doOperation(ret,bookList);
        }

//        System.out.println(ret);
//        System.out.println(user);
    }
}